package com.dream.base.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dream.app.cache.ProgressCache;
import com.dream.utils.annotation.AccessToken;
import com.dream.utils.annotation.AccessTokenType;
import com.dream.utils.annotation.SkipAuthority;

/**
 * @copyright evan
 * @author evan
 * @Revision
 * @date 2013/8/31
 */
@Controller
@RequestMapping(value = "/view")
public class ViewController extends BaseController {
	
	@Autowired
	private ProgressCache progressCache;
	
	@ResponseBody
	@RequestMapping(value = "/upload/progress")
	@SkipAuthority
	public Long getProgress(String fileId) {
		
		String key = getUser().getId().concat(fileId);
		return progressCache.getProgress(key);
		
	}
	
	@RequestMapping(value = "/page")
	@SkipAuthority
	public String page(String loc,Model modelMap) {
		
		return loc;
	}
	
	@RequestMapping(value = "/token/page")
	@AccessToken(AccessTokenType.generate)
	@SkipAuthority
	public String tokenPage(String loc) {
		
		return loc;
	}
	
}
